﻿using System;
using System.Globalization;
using Jayden.Dll.Web.Enums;
using Jayden.Dll.Web.HtmlControls.Descriptions;
using Jayden.Dll.Web.HtmlControls.Generics;

namespace Jayden.Dll.Web.HtmlControls
{
	public class Progress : HtmlElement
	{
		public Progress() : base(ProgressDescription.Instance) { }
		public Progress(string text)
			: this()
		{
			if (text != null)
				AddText(text);
		}

		public double Value { get { return double.Parse(this["value"] ?? "0", CultureInfo.InvariantCulture); } set { this["value"] = value.ToString(CultureInfo.InvariantCulture); } }
		public double Max { get { return double.Parse(this["max"] ?? "1", CultureInfo.InvariantCulture); } set { this["max"] = value.ToString(CultureInfo.InvariantCulture); } }
	}
	public class ProgressDescription : HtmlElementDescription
	{
		public static readonly ProgressDescription Instance = new ProgressDescription();
		private ProgressDescription() : base("progress", HtmlVersion.Html5) { }
		public override Type ControlType { get { return typeof(Progress); } }
		public override string Description { get { return "completion progress of a task."; } }
		public override bool IsFlowElement { get { return true; } }
		public override bool OnlyPhrasingContent { get { return true; } }
	}
}
